package com.liuyuxing.test.service.impl;

import com.liuyuxing.test.entity.Fruit;
import com.liuyuxing.test.service.PromotionStrategyService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscountPromotionStrategyServiceImpl implements PromotionStrategyService {
    @Override
    public double applyPromotion(List<Fruit> fruits) {
        double total = 0;
        for (Fruit fruit : fruits) {
            if (fruit.getName().equals("草莓")) {
                total += fruit.getPricePerPound() * fruit.getPounds() * 0.8;
            } else {
                total += fruit.getPricePerPound() * fruit.getPounds();
            }

        }
        // 假设草莓打8折
        return total;
    }
}
